Now we can use our random x-coordinate to place the ball!

  • Click the Codesters tab. Then, go to and drag Go To into your program.
  • Change the name in front of the .go_to() command to ball.
  • Replace the first number in the .go_to() command with x and the second with -25. Like this: (x, -25).

Now when we press Run the ball will go to a random position on the stage.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("halfcourt") sprite = codesters.Sprite("player4") sprite.go_to(215, -175) net = codesters.Sprite("basketballnet") net.go_to(215, 175) ball = codesters.Sprite("basketball") x = random.randint(-100, 150)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)